package com.markerhub.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private int code;
    /**错误原因**/
    private String msg;
    private Object data;

    /**传code,msg,data的成功方法**/
    public static Result baseResult(int code,String msg,Object data){
        Result result=new Result();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }
    /**只传成功消息**/
    public static Result success(Object data){
        return baseResult(200,"成功",data);
    }
    /**不带数据返回错误消息**/
    public static Result fail(int code,String msg){
        Result result=new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static Result fail(String msg){
        Result result=new Result();
        result.setMsg(msg);
        return result;
    }
    public static Result fail(int code,String msg,Object data){
        Result result=new Result();
        result.setCode(code);
        result.setData(data);
        result.setMsg(msg);
        return result;
    }
}